<?php
/**
 * Created by PhpStorm.
 * User: boye009
 * Date: 2016/3/11
 * Time: 16:30
 */

namespace Test\Controller;

use Common\Api\BoyeServiceApi;

class TestShoppingCartController extends TestController{

    public function add(){

        if(IS_POST){

            $data=array(
                'uid' => I('post.uid',0),
                'p_id' => I('post.p_id',0),
                'count' => I('post.count',0),
                'psku_id' => I('post.psku_id',0),
                'api_ver'=>$this->api_ver,
                'notify_id'=>$this->notify_id,
                'type'=>'BY_ShoppingCart_add',
                'alg'=>'md5',
            );

            $service = new BoyeServiceApi();

            $result = $service->callRemote("",$data,true);

            $this->parseResult($result);

        }

        $this->display();

    }

    public function delete(){

        if(IS_POST){

            $data=array(
                'id' => I('post.id',0),
                'api_ver'=>$this->api_ver,
                'notify_id'=>$this->notify_id,
                'type'=>'BY_ShoppingCart_delete',
                'alg'=>'md5',
            );

            $service = new BoyeServiceApi();

            $result = $service->callRemote("",$data,true);

            $this->parseResult($result);

        }

        $this->display();

    }

    public function count(){

        if(IS_POST){

            $data = array(
                'psku_id' => I('post.psku_id',0),
                'api_ver'=>$this->api_ver,
                'notify_id'=>$this->notify_id,
                'type'=>'BY_ShoppingCart_count',
                'alg'=>'md5',
            );


            $service = new BoyeServiceApi();

            $result = $service->callRemote("",$data,true);

            $this->parseResult($result);

        }
        $this->display();
    }

    public function query(){

        if(IS_POST){

            $data = array(
                'uid' => I('post.uid',0),
                'page_no' => I('post.page_no',0),
                'page_size' => I('post.page_size',10),
                'api_ver'=>$this->api_ver,
                'notify_id'=>$this->notify_id,
                'type'=>'BY_ShoppingCart_query',
                'alg'=>'md5',
            );


            $service = new BoyeServiceApi();

            $result = $service->callRemote("",$data,true);

            $this->parseResult($result);

        }
        $this->display();
    }

    public function getInfo(){

        if(IS_POST){

            $data = array(
                'id' => I('post.id',0),
                'api_ver'=>$this->api_ver,
                'notify_id'=>$this->notify_id,
                'type'=>'BY_ShoppingCart_getInfo',
                'alg'=>'md5',
            );


            $service = new BoyeServiceApi();

            $result = $service->callRemote("",$data,true);

            $this->parseResult($result);

        }
        $this->display();

    }

    private function parseResult($result){
        echo "解密后数据：";
        dump($result);
    }

}